
<template>
	<!-- 添加弹框 -->
	<el-dialog title="" visible :show-close="false" :modal-append-to-body="false" size="tiny" class="wrap">
		<i class="el-icon-close close" @click="cancel" style="color: white;z-index: 99;"></i>
		<div class="bt">仓库添加管理</div>
		<el-form label-width="100px" class="form">
		<el-form-item label="仓库名称">
 				<el-input v-model="vmc"  placeholder="请输入仓库名称" class="select-block"></el-input>
 		</el-form-item>

 		<el-form-item label="是否启用">
 				<el-select v-model="vtype"  placeholder="请选择仓库类型" class="select-block" >
					  <el-option label="启用" value="Y"></el-option>
					  <el-option label="禁用" value="N" ></el-option>
			    </el-select>
 		</el-form-item>

		<el-form-item label="描述">
 				<el-input v-model="vms" type="textarea"  :rows="4" placeholder="请输入内容" class="select-block"></el-input>
 		</el-form-item>
        </el-form>
		<el-button type="info" class="submit" @click="submit">保存</el-button>
	</el-dialog>
</template>
<script type="text/javascript">
	import qs from 'qs'
	export default {
		data() {
			return {
				vtype: '',
				vms: '',
				vmc: '',
				comboxlist:[],
				dialogTableVisible: true
			}
		},
		created(){
		 this.getcomboxlist();
	 },
		methods: {
			submit() {
				//检测

				this.$store.state.loading = true;
			    if(!this.vmc) {
					this.$message.warning('请填写仓库名称');
					this.$store.state.loading = false;
					return;
				}else if(!this.vtype){
					this.$message.warning('请选择仓库类型');
					this.$store.state.loading = false;
					return;
			    }
				var logininfo = JSON.parse(localStorage.logininfo);
				var params3 = qs.stringify({
					type: this.vtype,
					ms: this.vms,
					mc: this.vmc,
					yhid: logininfo.id,
					xxid:logininfo.xxid
				});
				//执行

				this.axios.post(this.$store.state.api + 'cku/insert', params3)
					.then(res => {
						if(res.data.code == 1) {
							this.$emit('close', { type: 'add', cancel: false });
							this.$store.state.loading = false;
						} else {
							this.$emit('close', { type: 'add', cancel: false });
							this.$store.state.loading = false;
						}
					}).catch(res => {
						this.$message.warning("服务器繁忙，请重试");
						//this.$emit('close', { type: 'add', cancel: false });
						this.$store.state.loading = false;
					})
			},
			getcomboxlist(){
				var logininfo = JSON.parse(localStorage.logininfo) ;
				var params3 = qs.stringify({
								yhid:logininfo.id,
								xxid:logininfo.xxid,
								pageindex: 1,
								pagesize: 1000
						});
					this.searchLoading = true;
					this.axios.post(this.$store.state.api + 'cku/list',params3)
					.then( res => {
							console.log(res)
							let data = res.data.data;
							let list = data.list;
							this.comboxlist=list;
							console.log(this.comboxlist)
					}).catch( res => {
							console.log(res)
							this.searchLoading = false;
					})
				},
			cancel() {
				this.$emit('close', { type: 'add', cancel: true })
			}
		}
	}
</script>
<style lang="less" scoped>
	.wrap {
		.input-block {
			margin-bottom: 20px;
			text-align: center;
		}
		.bt{
			position: absolute;
			width: 100%;
			height: 50px;
			margin: 0 auto;
			top:0;
			left:0;
			background: #50BFFF;
			margin-bottom: 20px;
			color:white;
			text-align:left;
			line-height: 50px;
			font-size: 17px;
			padding-left: 15px;
		}
		.form {
		text-align: center;
		margin-top:20px;
	}
	.select-block {
 		display: block;
 		width: 85%;
 	}
		.input {
			display: inline-block;
		}
		/*.input1 {
			width: 300px;
			display: inline-block;
			vertical-align: middle;
		}
		.input-block span {
			display: inline-block;
			width: 70px;
			text-align: right;
		}*/
		.submit {
			width: 120px;
			display: block;
			margin: 0 auto;
			margin-top: 20px;
		}
	}
</style>
